﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CheckExistUserServiceReference;
using AddUserServiceReference;

public partial class SignInPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Page_PreRender(object sender, EventArgs e)
    {
        ktNgaysinh.MaximumValue = DateTime.Now.Date.AddYears(-1).ToString("MM/dd/yyyy");
        ktNgaysinh.MinimumValue = DateTime.Now.Date.AddYears(-200).ToString("MM/dd/yyyy");
    }
    protected void UserName_TextChanged(object sender, EventArgs e)
    {
        if (existUser(UserName.Text))
        {
            ErrorLabel.Visible = true;
        }
        else
        {
            ErrorLabel.Visible = false;
        }

    }

    bool existUser(String userName)
    {
        CheckExistUserClient cesc = new CheckExistUserClient();
        return cesc.CheckExist(userName);
    }
    protected void bntSub_Click(object sender, EventArgs e)
    {
        if (ErrorLabel.Visible == false)
        {
            string gioitinh = SexRadioList.SelectedValue;
            DateTime ngay = Convert.ToDateTime(txtNgay.Text);
            AddUserClient auc = new AddUserClient();
            auc.AddNewUser(UserName.Text, Password.Text, Email.Text, txtTen.Text, gioitinh, ngay, txtAddress.Text, txtCountry.Text);
        }
    }
}